package com.cskaoyan.service;

import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.bean.po.MarketLog;
import com.cskaoyan.bean.po.MarketLogExample;
import com.cskaoyan.mapper.MarketLogMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: Yang Yi-zhou
 * @Date: 2022/9/7 12:29
 * @Description:
 */
@Service
public class MarketLogServiceImpl implements MarketLogService {

    @Autowired
    MarketLogMapper marketLogMapper;

    @Override
    public CommonData<MarketLog> listAdmin(Integer page, Integer limit, String sort, String order) {
        PageHelper.startPage(page, limit);
        MarketLogExample example = new MarketLogExample();
        example.setOrderByClause(sort + " " + order);
        List<MarketLog> marketLogs = marketLogMapper.selectByExample(example);
        PageInfo pageInfo = new PageInfo(marketLogs);
        return CommonData.data(pageInfo);
    }
}
